<cfif Not IsDefined("u") OR Not IsDefined("g")>
	<cfset session.message = "Incorrect Parameters!">
	<cflocation url="ListGroups.cfm">
</cfif>

<cfset UID = u>
<cfset GID = g>

<!---Only the owner of a group can promote a user!--->

<cfquery datasource="exp" name="Group">
	
	SELECT ownerID
	FROM groups
	WHERE id = #GID#
	
</cfquery>

<cfif Group.ownerID eq session.id>
	<cftry>
		<cftransaction>
			<cfquery datasource="exp">

				UPDATE groups
				SET ownerID = #UID#
				WHERE id = #GID#

			</cfquery>
		</cftransaction>
		<cfcatch type="Database">
			<cfset session.message = "Database Error!">
			<cflocation url="ListGroups.cfm">
		</cfcatch>
	</cftry>

	<cfset session.message = "User was promoted sucessfully!">
	<cflocation url="ListGroups.cfm">
<cfelse>
	<cfset session.message = "Insufficient privelages to promote user!">
	<cflocation url="ListGroups.cfm">
</cfif>
		

